package com.teamclub.util.libs;

import scala.tools.nsc.ast.TreeGen;

import java.util.List;

/**
 * Created by ilkkzm on 17-8-9.
 */
public class TreeGenerator {
    private Integer levelCount; //一层数量
    List<Integer> levelContent; //每层的内容

    public TreeGenerator() {
        this(3);
    }

    public TreeGenerator(Integer levelCount) {
        this.levelCount = levelCount;
    }


    public String geneSameLevel(String baseVal) {
        String first = baseVal.substring(0, baseVal.length() - this.levelCount);
        String second = baseVal.substring(baseVal.length() - this.levelCount);
        Integer num = Integer.parseInt(second);
        String formatStr = "%0" + this.levelCount + "d";
        String s = String.format(formatStr, num + 1);
        return first + s;
    }

    public String geneSubLevel(String baseVal) {
        String formatStr = "%0" + this.levelCount + "d";
        String s = String.format(formatStr, 1);
        return baseVal + s;
    }

    public static void main(String[] args) {
        TreeGenerator treeGenerator = new TreeGenerator();
        String s = treeGenerator.geneSameLevel("001");
        System.out.println(s);
        String ss = treeGenerator.geneSubLevel(s);
        System.out.println(ss);
        String sss = treeGenerator.geneSubLevel(ss);
        System.out.println(sss);
        System.out.println(String.format("%3d", 12));
    }
}
